/* Carnival Probability Simulator Styles */
/* Mobile-first responsive design with carnival theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 400% 400%;
    animation: carnivalBackground 8s ease-in-out infinite;
    height: 100vh;
    overflow-x: hidden;
}

/* Detect if in iframe and adjust height accordingly */
@media (max-height: 500px) {
    body {
        height: 450px;
    }
}

@media (min-height: 501px) {
    body {
        height: 90vh;
    }
}

/* Animated carnival background */
@keyframes carnivalBackground {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.carnival-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    position: relative;
}

/* Tooltip styles for header information */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Game selector buttons */
.game-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.game-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 4px;
    background: linear-gradient(45deg, #ff9a9e, #fecfef);
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #333;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.game-btn.active {
    background: linear-gradient(45deg, #ffd89b, #19547b);
    color: white;
    transform: scale(1.05);
}

/* Main game area */
.game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.game-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s ease;
    padding: 15px;
}

.game-panel.active {
    opacity: 1;
    transform: translateX(0);
}

.game-content {
    display: flex;
    height: 100%;
    gap: 15px;
    flex-direction: column;
}

/* Dartboard Game Styles */
.dartboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dartboard {
    width: 150px;
    height: 150px;
    position: relative;
    border-radius: 50%;
    margin-bottom: 15px;
    cursor: crosshair;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.3s ease;
}

.outer-ring {
    width: 100%;
    height: 100%;
    background: #ff6b6b;
    top: 0;
    left: 0;
}

.middle-ring {
    width: 75%;
    height: 75%;
    background: #4ecdc4;
    top: 12.5%;
    left: 12.5%;
}

.inner-ring {
    width: 50%;
    height: 50%;
    background: #45b7d1;
    top: 25%;
    left: 25%;
}

.bullseye {
    width: 25%;
    height: 25%;
    background: #f9ca24;
    top: 37.5%;
    left: 37.5%;
}

.ring:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

/* Button styles */
.throw-btn, .toss-btn, .draw-btn, .flip-btn, .reset-btn {
    padding: 12px 24px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 44px; /* Touch-friendly size */
}

.throw-btn:hover, .toss-btn:hover, .draw-btn:hover, .flip-btn:hover, .reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Ring Toss Game Styles */
.ringtoss-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pegs {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.peg {
    width: 40px;
    height: 60px;
    background: linear-gradient(to bottom, #8b4513, #a0522d);
    border-radius: 20px 20px 5px 5px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.peg::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 10px;
    background: #654321;
    border-radius: 50%;
}

.peg[data-difficulty="easy"] {
    background: linear-gradient(to bottom, #4CAF50, #45a049);
}

.peg[data-difficulty="medium"] {
    background: linear-gradient(to bottom, #ff9800, #e68900);
}

.peg[data-difficulty="hard"] {
    background: linear-gradient(to bottom, #f44336, #d32f2f);
}

.peg:hover {
    transform: scale(1.1);
}

/* Lucky Draw Game Styles */
.draw-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ball-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.ball {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #333;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.ball.red { background: #ff4757; }
.ball.blue { background: #3742fa; }
.ball.green { background: #2ed573; }
.ball.yellow { background: #ffa502; }

.ball:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.ball.drawn {
    opacity: 0.3;
    transform: scale(0.8);
}

.draw-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.drawn-balls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 50px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    width: 100%;
}

/* Coin Toss Game Styles */
.coin-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.coin {
    width: 100px;
    height: 100px;
    position: relative;
    margin-bottom: 20px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 1s;
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    border: 4px solid #333;
    backface-visibility: hidden;
}

.heads {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
}

.tails {
    background: linear-gradient(45deg, #c0c0c0, #e8e8e8);
    color: #333;
    transform: rotateY(180deg);
}

.coin.flipping {
    animation: coinFlip 1s ease-in-out;
}

@keyframes coinFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(900deg) scale(1.1); }
    100% { transform: rotateY(1800deg); }
}

/* Probability Panel Styles */
.probability-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.probability-panel h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
    text-align: center;
}

.prob-input {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.prob-input label {
    font-size: 12px;
    font-weight: bold;
    color: #555;
}

.prob-input input, .prob-input select {
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    min-height: 44px; /* Touch-friendly */
}

.prob-input input:focus, .prob-input select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat {
    background: rgba(102, 126, 234, 0.1);
    padding: 8px;
    border-radius: 5px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
}

.stat span {
    color: #667eea;
    font-size: 14px;
}

/* Global Controls */
.global-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.reset-all-btn {
    padding: 10px 20px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.reset-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.help-text {
    font-size: 11px;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 15px;
    cursor: help;
}

/* Responsive Design */
@media (min-width: 768px) {
    .carnival-container {
        padding: 20px;
    }
    
    .game-content {
        flex-direction: row;
    }
    
    .dartboard-container,
    .ringtoss-container,
    .draw-container,
    .coin-container {
        flex: 2;
    }
    
    .probability-panel {
        flex: 1;
        max-width: 300px;
    }
    
    .results {
        grid-template-columns: 1fr;
    }
    
    .game-btn {
        font-size: 14px;
        padding: 12px 8px;
    }
}

/* Animation for successful hits */
.success-animation {
    animation: successPulse 0.6s ease-in-out;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); box-shadow: 0 0 30px #4CAF50; }
}

/* Loading animation for buttons */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}